Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/genpolicy: never log existing policy annotation on 'debug' + handle missing log prefix #1061

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

jmxnzo
Copy link
Contributor

@jmxnzo jmxnzo commented Dec 9, 2024

This PR is a follow up on #1054 and patches the occurred runtime error on the different kata-containers upstream repos, by redacting existing policy annotations when logging. Thus the RUST_LOG env flag can now be set to "debug" and re-running the generate step on a deployment with set policy annotation does not result in a runtime error during translation anymore.
Nevertheless the default log level of genpolicy in the Contrast CLI is kept as 'info' and parsing the 'debug' logs needs to be configured manually by setting the RUST_LOG env to 'debug'.

In some cases the genpolicy tool does not use the logger to write to stderr, the logtranslator.go additionally was rewritten to continue logging on the latest log level in case of missing log prefix. As well a simple regex was introduced to extract error messages from stderr of genpolicy and translate them to 'ERROR' logging in Contrast CLI, as they are also missing a logging prefix.

Upstream PR: kata-containers/kata-containers#10647

@jmxnzo jmxnzo added the bug fix Fixing a user facing bug label Dec 9, 2024
@jmxnzo jmxnzo requested a review from burgerdev December 9, 2024 16:51
@jmxnzo jmxnzo requested a review from katexochen as a code owner December 9, 2024 16:51
@jmxnzo jmxnzo force-pushed the genpolicy/logging-jla branch from a8b4956 to e62f731 Compare December 9, 2024 16:59
@jmxnzo jmxnzo force-pushed the genpolicy/logging-jla branch from e62f731 to 45a9824 Compare December 11, 2024 10:08
Copy link
Contributor

@burgerdev burgerdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jmxnzo jmxnzo merged commit 3f39682 into main Dec 11, 2024
13 checks passed
@jmxnzo jmxnzo deleted the genpolicy/logging-jla branch December 11, 2024 16:37
@katexochen katexochen changed the title cli/genpolicy: never log already existing policy annotation on 'debug' + handle missing log prefix cli/genpolicy: never log existing policy annotation on 'debug' + handle missing log prefix Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Fixing a user facing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants